* DHS Calendar Tutorial - Example 2. * Last pregnancy, duration of pregnancy and method used before pregnancy. * download the model dataset for individual women's recode: "ZZIR62FL.SAV" * the model datasets are available at http://dhsprogram.com/data/download-model-datasets.cfm . * change to a working directory where the data are stored * or add the full path to the 'get file' command below. cd "C:\Data\DHS_model". * open the dataset to use, and just keep the variables we are going to use. get file="ZZIR62FL.SAV" / keep vcal$1 v000 v005 v007 v008 v017 v018 v019 v208 b3$01. * set maximum number of loops high enough. Could be as many as the length of the calendar (80) * so set it a bit higher. set mxloops = 100. * Example 2A. * -----------------------. * get century month code (CMC) of date of last birth or pregnancy from calendar * using string functions. * Step 2.1. * length of full calendar string including leading blanks (80). * actual length used according to v019 will be less. compute vcal_len = char.length(vcal$1). variable labels vcal_len "Length of calendar". print formats vcal_len (f2.0). * Step 2.2. * position of last birth or terminated pregnancy in calendar. compute lb = char.index(vcal$1,"B"). compute lp = char.index(vcal$1,"T"). * update lp with position of last birth if there was no terminated pregnancy, * or if the last birth was more recent than last terminated pregnancy. if (lp = 0 | (lb > 0 & lb < lp)) lp = lb. * e.g. if calendar is as below ("_" used to replace blank for display here): * ______________00000BPPPPPPPP000000555555500000TPP00000000000000BPPPPPPPP00000000 * ^. * lp would be 20. variable labels lp "Position of last birth or terminated pregnancy in calendar". value labels lp 0 "No birth or terminated pregnancy in calendar". print formats lp (f2.0). * get the type of birth or terminated pregnancy. * lp_type will be set to 1 if lp refers to a birth, * and 2 if lp refers to a terminated pregnancy using the position in "BT" for the resulting code. if (lp > 0) lp_type = char.index("BT",char.substr(vcal$1,lp,1)). variable labels lp_type "Birth or terminated pregnancy in calendar". value labels lp_type 1 "Birth" 2 "Terminated pregnancy". print formats lp_type (f1.0). list variables = vcal$1 lp lp_type /cases from 1 to 5. List Notes |---------------------------------------------|------------------------------------------------------| |Output Created |31-AUG-2017 01:10:46 | |---------------------------------------------|------------------------------------------------------| |Comments | | |--------------|------------------------------|------------------------------------------------------| |Input |Filter | | | |------------------------------|------------------------------------------------------| | |Weight | | | |------------------------------|------------------------------------------------------| | |Split File | | | |------------------------------|------------------------------------------------------| | |N of Rows in Working Data File|8348 | |---------------------------------------------|------------------------------------------------------| |Syntax |list variables = vcal$1 lp lp_type /cases from 1 to 5.| |--------------|------------------------------|------------------------------------------------------| |Resources |Processor Time |00:00:00.34 | | |------------------------------|------------------------------------------------------| | |Elapsed Time |00:00:00.34 | |----------------------------------------------------------------------------------------------------| The variables are listed in the following order: LINE 1: VCAL$1 LINE 2: lp lp_type VCAL$1: 00000BPPPPPPPP00000000000000000000000BPPPPPPPP00000000000000000000 lp: 20 1 VCAL$1: PPPPPP000000000000000000000000BPPPPPPPP000000000000000000000000000 lp: 45 1 VCAL$1: 000000000000000000000000000000000000000000000000000000000000000000 lp: 0 . VCAL$1: 0000000000BPPPPPPPP00000000000BPPPPPPPP000000000000000000000000000 lp: 25 1 VCAL$1: 0BPPPPPPPP000000000000000000000000BPPPPPPPP00000000000000000000000 lp: 16 1 Number of cases read: 5 Number of cases listed: 5 crosstabs /tables=lp by lp_type /count=asis. Crosstabs Notes |-----------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------| |Output Created |31-AUG-2017 01:10:46 | |-----------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------| |Comments | | |----------------------|------------------------------|-------------------------------------------------------------------------------------------------------------------------------| |Input |Filter | | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | |Weight | | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | |Split File | | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | |N of Rows in Working Data File|8348 | |----------------------|------------------------------|-------------------------------------------------------------------------------------------------------------------------------| |Missing Value Handling|Definition of Missing |User-defined missing values are treated as missing. | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | |Cases Used |Statistics for each table are based on all the cases with valid data in the specified range(s) for all variables in each table.| |-----------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------| |Syntax |crosstabs /tables=lp by lp_type /count=asis. | |----------------------|------------------------------|-------------------------------------------------------------------------------------------------------------------------------| |Resources |Processor Time |00:00:00.28 | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | |Elapsed Time |00:00:00.31 | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | |Dimensions Requested |2 | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | |Cells Available |131029 | |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| Case Processing Summary |-----------------------------------------------------------------------------------------------------------------|-------------------------------------------| | |Cases | | |-------------|---------------|-------------| | |Valid |Missing |Total | | |-----|-------|-------|-------|-----|-------| | |N |Percent|N |Percent|N |Percent| |-----------------------------------------------------------------------------------------------------------------|-----|-------|-------|-------|-----|-------| |lp Position of last birth or terminated pregnancy in calendar * lp_type Birth or terminated pregnancy in calendar|4691 |56.2% |3657 |43.8% |8348 |100.0% | |-------------------------------------------------------------------------------------------------------------------------------------------------------------| lp Position of last birth or terminated pregnancy in calendar * lp_type Birth or terminated pregnancy in calendar Crosstabulation Count |----------------------------------------------------------------|----------------------------------------------------------------------|-----| | |lp_type Birth or terminated pregnancy in calendar |Total| | |-------------------------------------------------|--------------------| | | |Birth |Terminated pregnancy| | |-------------------------------------------------------------|--|-------------------------------------------------|--------------------|-----| |lp Position of last birth or terminated pregnancy in calendar|11|1 |0 |1 | | |--|-------------------------------------------------|--------------------|-----| | |12|15 |0 |15 | | |--|-------------------------------------------------|--------------------|-----| | |13|36 |3 |39 | | |--|-------------------------------------------------|--------------------|-----| | |14|59 |5 |64 | | |--|-------------------------------------------------|--------------------|-----| | |15|105 |14 |119 | | |--|-------------------------------------------------|--------------------|-----| | |16|112 |3 |115 | | |--|-------------------------------------------------|--------------------|-----| | |17|115 |14 |129 | | |--|-------------------------------------------------|--------------------|-----| | |18|117 |9 |126 | | |--|-------------------------------------------------|--------------------|-----| | |19|115 |8 |123 | | |--|-------------------------------------------------|--------------------|-----| | |20|135 |4 |139 | | |--|-------------------------------------------------|--------------------|-----| | |21|97 |10 |107 | | |--|-------------------------------------------------|--------------------|-----| | |22|92 |3 |95 | | |--|-------------------------------------------------|--------------------|-----| | |23|108 |9 |117 | | |--|-------------------------------------------------|--------------------|-----| | |24|93 |7 |100 | | |--|-------------------------------------------------|--------------------|-----| | |25|88 |9 |97 | | |--|-------------------------------------------------|--------------------|-----| | |26|122 |5 |127 | | |--|-------------------------------------------------|--------------------|-----| | |27|123 |3 |126 | | |--|-------------------------------------------------|--------------------|-----| | |28|110 |7 |117 | | |--|-------------------------------------------------|--------------------|-----| | |29|106 |8 |114 | | |--|-------------------------------------------------|--------------------|-----| | |30|106 |11 |117 | | |--|-------------------------------------------------|--------------------|-----| | |31|95 |5 |100 | | |--|-------------------------------------------------|--------------------|-----| | |32|101 |6 |107 | | |--|-------------------------------------------------|--------------------|-----| | |33|72 |4 |76 | | |--|-------------------------------------------------|--------------------|-----| | |34|55 |2 |57 | | |--|-------------------------------------------------|--------------------|-----| | |35|68 |1 |69 | | |--|-------------------------------------------------|--------------------|-----| | |36|55 |4 |59 | | |--|-------------------------------------------------|--------------------|-----| | |37|73 |5 |78 | | |--|-------------------------------------------------|--------------------|-----| | |38|97 |2 |99 | | |--|-------------------------------------------------|--------------------|-----| | |39|99 |4 |103 | | |--|-------------------------------------------------|--------------------|-----| | |40|99 |1 |100 | | |--|-------------------------------------------------|--------------------|-----| | |41|103 |6 |109 | | |--|-------------------------------------------------|--------------------|-----| | |42|85 |10 |95 | | |--|-------------------------------------------------|--------------------|-----| | |43|62 |2 |64 | | |--|-------------------------------------------------|--------------------|-----| | |44|56 |2 |58 | | |--|-------------------------------------------------|--------------------|-----| | |45|53 |4 |57 | | |--|-------------------------------------------------|--------------------|-----| | |46|40 |0 |40 | | |--|-------------------------------------------------|--------------------|-----| | |47|41 |2 |43 | | |--|-------------------------------------------------|--------------------|-----| | |48|47 |3 |50 | | |--|-------------------------------------------------|--------------------|-----| | |49|64 |6 |70 | | |--|-------------------------------------------------|--------------------|-----| | |50|65 |2 |67 | | |--|-------------------------------------------------|--------------------|-----| | |51|76 |4 |80 | | |--|-------------------------------------------------|--------------------|-----| | |52|73 |9 |82 | | |--|-------------------------------------------------|--------------------|-----| | |53|81 |1 |82 | | |--|-------------------------------------------------|--------------------|-----| | |54|71 |3 |74 | | |--|-------------------------------------------------|--------------------|-----| | |55|38 |0 |38 | | |--|-------------------------------------------------|--------------------|-----| | |56|46 |0 |46 | | |--|-------------------------------------------------|--------------------|-----| | |57|33 |2 |35 | | |--|-------------------------------------------------|--------------------|-----| | |58|23 |3 |26 | | |--|-------------------------------------------------|--------------------|-----| | |59|20 |1 |21 | | |--|-------------------------------------------------|--------------------|-----| | |60|37 |1 |38 | | |--|-------------------------------------------------|--------------------|-----| | |61|34 |3 |37 | | |--|-------------------------------------------------|--------------------|-----| | |62|30 |1 |31 | | |--|-------------------------------------------------|--------------------|-----| | |63|39 |2 |41 | | |--|-------------------------------------------------|--------------------|-----| | |64|47 |1 |48 | | |--|-------------------------------------------------|--------------------|-----| | |65|62 |8 |70 | | |--|-------------------------------------------------|--------------------|-----| | |66|46 |5 |51 | | |--|-------------------------------------------------|--------------------|-----| | |67|25 |2 |27 | | |--|-------------------------------------------------|--------------------|-----| | |68|26 |1 |27 | | |--|-------------------------------------------------|--------------------|-----| | |69|22 |2 |24 | | |--|-------------------------------------------------|--------------------|-----| | |70|25 |0 |25 | | |--|-------------------------------------------------|--------------------|-----| | |71|14 |2 |16 | | |--|-------------------------------------------------|--------------------|-----| | |72|19 |0 |19 | | |--|-------------------------------------------------|--------------------|-----| | |73|30 |1 |31 | | |--|-------------------------------------------------|--------------------|-----| | |74|26 |3 |29 | | |--|-------------------------------------------------|--------------------|-----| | |75|38 |0 |38 | | |--|-------------------------------------------------|--------------------|-----| | |76|55 |1 |56 | | |--|-------------------------------------------------|--------------------|-----| | |77|34 |1 |35 | | |--|-------------------------------------------------|--------------------|-----| | |78|30 |2 |32 | | |--|-------------------------------------------------|--------------------|-----| | |79|18 |0 |18 | | |--|-------------------------------------------------|--------------------|-----| | |80|25 |1 |26 | |----------------------------------------------------------------|-------------------------------------------------|--------------------|-----| |Total |4428 |263 |4691 | |---------------------------------------------------------------------------------------------------------------------------------------------| * Step 2.3. * if there is a birth or terminated pregnancy in the calendar then calculate CMC * of date of last birth or pregnancy by adding length of calendar to start CMC * less the position of the birth or pregnancy. * calendar starts in CMC given in V017. * lp > 0 means there was a birth or terminated pregnancy in the calendar. if (lp > 0) cmc_lp = V017 + vcal_len - lp. variable labels cmc_lp "Century month code of last pregnancy". print formats cmc_lp (f4.0). * e.g. if calendar is as below and cmc of beginning of calendar (V017) = 1321: * ______________00000BPPPPPPPP000000555555500000TPP00000000000000BPPPPPPPP00000000 * cmc_lp would be 1381, calculation as follows: * 1321 + 80 - 20 (80 is the vcal_len, and 20 is the position of lp). list variables = V017 lp vcal_len cmc_lp /cases from 1 to 5. List Notes |---------------------------------------------|------------------------------------------------------------| |Output Created |31-AUG-2017 01:10:46 | |---------------------------------------------|------------------------------------------------------------| |Comments | | |--------------|------------------------------|------------------------------------------------------------| |Input |Filter | | | |------------------------------|------------------------------------------------------------| | |Weight | | | |------------------------------|------------------------------------------------------------| | |Split File | | | |------------------------------|------------------------------------------------------------| | |N of Rows in Working Data File|8348 | |---------------------------------------------|------------------------------------------------------------| |Syntax |list variables = V017 lp vcal_len cmc_lp /cases from 1 to 5.| |--------------|------------------------------|------------------------------------------------------------| |Resources |Processor Time |00:00:00.30 | | |------------------------------|------------------------------------------------------------| | |Elapsed Time |00:00:00.31 | |----------------------------------------------------------------------------------------------------------| V017 lp vcal_len cmc_lp 1321 20 80 1381 1321 45 80 1356 1321 0 80 . 1321 25 80 1376 1321 16 80 1385 Number of cases read: 5 Number of cases listed: 5 * check the variables created. frequencies variables=lp cmc_lp. Frequencies Notes |-----------------------------------------------------|---------------------------------------------------| |Output Created |31-AUG-2017 01:10:47 | |-----------------------------------------------------|---------------------------------------------------| |Comments | | |----------------------|------------------------------|---------------------------------------------------| |Input |Filter | | | |------------------------------|---------------------------------------------------| | |Weight | | | |------------------------------|---------------------------------------------------| | |Split File | | | |------------------------------|---------------------------------------------------| | |N of Rows in Working Data File|8348 | |----------------------|------------------------------|---------------------------------------------------| |Missing Value Handling|Definition of Missing |User-defined missing values are treated as missing.| | |------------------------------|---------------------------------------------------| | |Cases Used |Statistics are based on all cases with valid data. | |-----------------------------------------------------|---------------------------------------------------| |Syntax |frequencies variables=lp cmc_lp. | |----------------------|------------------------------|---------------------------------------------------| |Resources |Processor Time |00:00:00.02 | | |------------------------------|---------------------------------------------------| | |Elapsed Time |00:00:00.01 | |---------------------------------------------------------------------------------------------------------| Statistics |---------|-------------------------------------------------------------|-------------------------------------------| | |lp Position of last birth or terminated pregnancy in calendar|cmc_lp Century month code of last pregnancy| |-|-------|-------------------------------------------------------------|-------------------------------------------| |N|Valid |8348 |4691 | | |-------|-------------------------------------------------------------|-------------------------------------------| | |Missing|0 |3657 | |-------------------------------------------------------------------------------------------------------------------| Frequency Table lp Position of last birth or terminated pregnancy in calendar |--------------------------------------------------|---------|-------|-------------|------------------| | |Frequency|Percent|Valid Percent|Cumulative Percent| |-----|--------------------------------------------|---------|-------|-------------|------------------| |Valid|No birth or terminated pregnancy in calendar|3657 |43.8 |43.8 |43.8 | | |--------------------------------------------|---------|-------|-------------|------------------| | |11 |1 |.0 |.0 |43.8 | | |--------------------------------------------|---------|-------|-------------|------------------| | |12 |15 |.2 |.2 |44.0 | | |--------------------------------------------|---------|-------|-------------|------------------| | |13 |39 |.5 |.5 |44.5 | | |--------------------------------------------|---------|-------|-------------|------------------| | |14 |64 |.8 |.8 |45.2 | | |--------------------------------------------|---------|-------|-------------|------------------| | |15 |119 |1.4 |1.4 |46.7 | | |--------------------------------------------|---------|-------|-------------|------------------| | |16 |115 |1.4 |1.4 |48.0 | | |--------------------------------------------|---------|-------|-------------|------------------| | |17 |129 |1.5 |1.5 |49.6 | | |--------------------------------------------|---------|-------|-------------|------------------| | |18 |126 |1.5 |1.5 |51.1 | | |--------------------------------------------|---------|-------|-------------|------------------| | |19 |123 |1.5 |1.5 |52.6 | | |--------------------------------------------|---------|-------|-------------|------------------| | |20 |139 |1.7 |1.7 |54.2 | | |--------------------------------------------|---------|-------|-------------|------------------| | |21 |107 |1.3 |1.3 |55.5 | | |--------------------------------------------|---------|-------|-------------|------------------| | |22 |95 |1.1 |1.1 |56.6 | | |--------------------------------------------|---------|-------|-------------|------------------| | |23 |117 |1.4 |1.4 |58.0 | | |--------------------------------------------|---------|-------|-------------|------------------| | |24 |100 |1.2 |1.2 |59.2 | | |--------------------------------------------|---------|-------|-------------|------------------| | |25 |97 |1.2 |1.2 |60.4 | | |--------------------------------------------|---------|-------|-------------|------------------| | |26 |127 |1.5 |1.5 |61.9 | | |--------------------------------------------|---------|-------|-------------|------------------| | |27 |126 |1.5 |1.5 |63.4 | | |--------------------------------------------|---------|-------|-------------|------------------| | |28 |117 |1.4 |1.4 |64.8 | | |--------------------------------------------|---------|-------|-------------|------------------| | |29 |114 |1.4 |1.4 |66.2 | | |--------------------------------------------|---------|-------|-------------|------------------| | |30 |117 |1.4 |1.4 |67.6 | | |--------------------------------------------|---------|-------|-------------|------------------| | |31 |100 |1.2 |1.2 |68.8 | | |--------------------------------------------|---------|-------|-------------|------------------| | |32 |107 |1.3 |1.3 |70.1 | | |--------------------------------------------|---------|-------|-------------|------------------| | |33 |76 |.9 |.9 |71.0 | | |--------------------------------------------|---------|-------|-------------|------------------| | |34 |57 |.7 |.7 |71.7 | | |--------------------------------------------|---------|-------|-------------|------------------| | |35 |69 |.8 |.8 |72.5 | | |--------------------------------------------|---------|-------|-------------|------------------| | |36 |59 |.7 |.7 |73.2 | | |--------------------------------------------|---------|-------|-------------|------------------| | |37 |78 |.9 |.9 |74.1 | | |--------------------------------------------|---------|-------|-------------|------------------| | |38 |99 |1.2 |1.2 |75.3 | | |--------------------------------------------|---------|-------|-------------|------------------| | |39 |103 |1.2 |1.2 |76.6 | | |--------------------------------------------|---------|-------|-------------|------------------| | |40 |100 |1.2 |1.2 |77.8 | | |--------------------------------------------|---------|-------|-------------|------------------| | |41 |109 |1.3 |1.3 |79.1 | | |--------------------------------------------|---------|-------|-------------|------------------| | |42 |95 |1.1 |1.1 |80.2 | | |--------------------------------------------|---------|-------|-------------|------------------| | |43 |64 |.8 |.8 |81.0 | | |--------------------------------------------|---------|-------|-------------|------------------| | |44 |58 |.7 |.7 |81.7 | | |--------------------------------------------|---------|-------|-------------|------------------| | |45 |57 |.7 |.7 |82.4 | | |--------------------------------------------|---------|-------|-------------|------------------| | |46 |40 |.5 |.5 |82.8 | | |--------------------------------------------|---------|-------|-------------|------------------| | |47 |43 |.5 |.5 |83.3 | | |--------------------------------------------|---------|-------|-------------|------------------| | |48 |50 |.6 |.6 |83.9 | | |--------------------------------------------|---------|-------|-------------|------------------| | |49 |70 |.8 |.8 |84.8 | | |--------------------------------------------|---------|-------|-------------|------------------| | |50 |67 |.8 |.8 |85.6 | | |--------------------------------------------|---------|-------|-------------|------------------| | |51 |80 |1.0 |1.0 |86.5 | | |--------------------------------------------|---------|-------|-------------|------------------| | |52 |82 |1.0 |1.0 |87.5 | | |--------------------------------------------|---------|-------|-------------|------------------| | |53 |82 |1.0 |1.0 |88.5 | | |--------------------------------------------|---------|-------|-------------|------------------| | |54 |74 |.9 |.9 |89.4 | | |--------------------------------------------|---------|-------|-------------|------------------| | |55 |38 |.5 |.5 |89.9 | | |--------------------------------------------|---------|-------|-------------|------------------| | |56 |46 |.6 |.6 |90.4 | | |--------------------------------------------|---------|-------|-------------|------------------| | |57 |35 |.4 |.4 |90.8 | | |--------------------------------------------|---------|-------|-------------|------------------| | |58 |26 |.3 |.3 |91.1 | | |--------------------------------------------|---------|-------|-------------|------------------| | |59 |21 |.3 |.3 |91.4 | | |--------------------------------------------|---------|-------|-------------|------------------| | |60 |38 |.5 |.5 |91.8 | | |--------------------------------------------|---------|-------|-------------|------------------| | |61 |37 |.4 |.4 |92.3 | | |--------------------------------------------|---------|-------|-------------|------------------| | |62 |31 |.4 |.4 |92.7 | | |--------------------------------------------|---------|-------|-------------|------------------| | |63 |41 |.5 |.5 |93.1 | | |--------------------------------------------|---------|-------|-------------|------------------| | |64 |48 |.6 |.6 |93.7 | | |--------------------------------------------|---------|-------|-------------|------------------| | |65 |70 |.8 |.8 |94.6 | | |--------------------------------------------|---------|-------|-------------|------------------| | |66 |51 |.6 |.6 |95.2 | | |--------------------------------------------|---------|-------|-------------|------------------| | |67 |27 |.3 |.3 |95.5 | | |--------------------------------------------|---------|-------|-------------|------------------| | |68 |27 |.3 |.3 |95.8 | | |--------------------------------------------|---------|-------|-------------|------------------| | |69 |24 |.3 |.3 |96.1 | | |--------------------------------------------|---------|-------|-------------|------------------| | |70 |25 |.3 |.3 |96.4 | | |--------------------------------------------|---------|-------|-------------|------------------| | |71 |16 |.2 |.2 |96.6 | | |--------------------------------------------|---------|-------|-------------|------------------| | |72 |19 |.2 |.2 |96.8 | | |--------------------------------------------|---------|-------|-------------|------------------| | |73 |31 |.4 |.4 |97.2 | | |--------------------------------------------|---------|-------|-------------|------------------| | |74 |29 |.3 |.3 |97.5 | | |--------------------------------------------|---------|-------|-------------|------------------| | |75 |38 |.5 |.5 |98.0 | | |--------------------------------------------|---------|-------|-------------|------------------| | |76 |56 |.7 |.7 |98.7 | | |--------------------------------------------|---------|-------|-------------|------------------| | |77 |35 |.4 |.4 |99.1 | | |--------------------------------------------|---------|-------|-------------|------------------| | |78 |32 |.4 |.4 |99.5 | | |--------------------------------------------|---------|-------|-------------|------------------| | |79 |18 |.2 |.2 |99.7 | | |--------------------------------------------|---------|-------|-------------|------------------| | |80 |26 |.3 |.3 |100.0 | | |--------------------------------------------|---------|-------|-------------|------------------| | |Total |8348 |100.0 |100.0 | | |-----------------------------------------------------------------------------------------------------| cmc_lp Century month code of last pregnancy |--------------|---------|-------|-------------|------------------| | |Frequency|Percent|Valid Percent|Cumulative Percent| |-------|------|---------|-------|-------------|------------------| |Valid |1321 |26 |.3 |.6 |.6 | | |------|---------|-------|-------------|------------------| | |1322 |18 |.2 |.4 |.9 | | |------|---------|-------|-------------|------------------| | |1323 |32 |.4 |.7 |1.6 | | |------|---------|-------|-------------|------------------| | |1324 |35 |.4 |.7 |2.4 | | |------|---------|-------|-------------|------------------| | |1325 |56 |.7 |1.2 |3.6 | | |------|---------|-------|-------------|------------------| | |1326 |38 |.5 |.8 |4.4 | | |------|---------|-------|-------------|------------------| | |1327 |29 |.3 |.6 |5.0 | | |------|---------|-------|-------------|------------------| | |1328 |31 |.4 |.7 |5.6 | | |------|---------|-------|-------------|------------------| | |1329 |19 |.2 |.4 |6.1 | | |------|---------|-------|-------------|------------------| | |1330 |16 |.2 |.3 |6.4 | | |------|---------|-------|-------------|------------------| | |1331 |25 |.3 |.5 |6.9 | | |------|---------|-------|-------------|------------------| | |1332 |24 |.3 |.5 |7.4 | | |------|---------|-------|-------------|------------------| | |1333 |27 |.3 |.6 |8.0 | | |------|---------|-------|-------------|------------------| | |1334 |27 |.3 |.6 |8.6 | | |------|---------|-------|-------------|------------------| | |1335 |51 |.6 |1.1 |9.7 | | |------|---------|-------|-------------|------------------| | |1336 |70 |.8 |1.5 |11.2 | | |------|---------|-------|-------------|------------------| | |1337 |48 |.6 |1.0 |12.2 | | |------|---------|-------|-------------|------------------| | |1338 |41 |.5 |.9 |13.1 | | |------|---------|-------|-------------|------------------| | |1339 |31 |.4 |.7 |13.7 | | |------|---------|-------|-------------|------------------| | |1340 |37 |.4 |.8 |14.5 | | |------|---------|-------|-------------|------------------| | |1341 |38 |.5 |.8 |15.3 | | |------|---------|-------|-------------|------------------| | |1342 |21 |.3 |.4 |15.8 | | |------|---------|-------|-------------|------------------| | |1343 |26 |.3 |.6 |16.3 | | |------|---------|-------|-------------|------------------| | |1344 |35 |.4 |.7 |17.1 | | |------|---------|-------|-------------|------------------| | |1345 |46 |.6 |1.0 |18.1 | | |------|---------|-------|-------------|------------------| | |1346 |38 |.5 |.8 |18.9 | | |------|---------|-------|-------------|------------------| | |1347 |74 |.9 |1.6 |20.4 | | |------|---------|-------|-------------|------------------| | |1348 |82 |1.0 |1.7 |22.2 | | |------|---------|-------|-------------|------------------| | |1349 |82 |1.0 |1.7 |23.9 | | |------|---------|-------|-------------|------------------| | |1350 |80 |1.0 |1.7 |25.6 | | |------|---------|-------|-------------|------------------| | |1351 |67 |.8 |1.4 |27.1 | | |------|---------|-------|-------------|------------------| | |1352 |70 |.8 |1.5 |28.6 | | |------|---------|-------|-------------|------------------| | |1353 |50 |.6 |1.1 |29.6 | | |------|---------|-------|-------------|------------------| | |1354 |43 |.5 |.9 |30.5 | | |------|---------|-------|-------------|------------------| | |1355 |40 |.5 |.9 |31.4 | | |------|---------|-------|-------------|------------------| | |1356 |57 |.7 |1.2 |32.6 | | |------|---------|-------|-------------|------------------| | |1357 |58 |.7 |1.2 |33.9 | | |------|---------|-------|-------------|------------------| | |1358 |64 |.8 |1.4 |35.2 | | |------|---------|-------|-------------|------------------| | |1359 |95 |1.1 |2.0 |37.2 | | |------|---------|-------|-------------|------------------| | |1360 |109 |1.3 |2.3 |39.6 | | |------|---------|-------|-------------|------------------| | |1361 |100 |1.2 |2.1 |41.7 | | |------|---------|-------|-------------|------------------| | |1362 |103 |1.2 |2.2 |43.9 | | |------|---------|-------|-------------|------------------| | |1363 |99 |1.2 |2.1 |46.0 | | |------|---------|-------|-------------|------------------| | |1364 |78 |.9 |1.7 |47.7 | | |------|---------|-------|-------------|------------------| | |1365 |59 |.7 |1.3 |48.9 | | |------|---------|-------|-------------|------------------| | |1366 |69 |.8 |1.5 |50.4 | | |------|---------|-------|-------------|------------------| | |1367 |57 |.7 |1.2 |51.6 | | |------|---------|-------|-------------|------------------| | |1368 |76 |.9 |1.6 |53.2 | | |------|---------|-------|-------------|------------------| | |1369 |107 |1.3 |2.3 |55.5 | | |------|---------|-------|-------------|------------------| | |1370 |100 |1.2 |2.1 |57.6 | | |------|---------|-------|-------------|------------------| | |1371 |117 |1.4 |2.5 |60.1 | | |------|---------|-------|-------------|------------------| | |1372 |114 |1.4 |2.4 |62.6 | | |------|---------|-------|-------------|------------------| | |1373 |117 |1.4 |2.5 |65.1 | | |------|---------|-------|-------------|------------------| | |1374 |126 |1.5 |2.7 |67.7 | | |------|---------|-------|-------------|------------------| | |1375 |127 |1.5 |2.7 |70.5 | | |------|---------|-------|-------------|------------------| | |1376 |97 |1.2 |2.1 |72.5 | | |------|---------|-------|-------------|------------------| | |1377 |100 |1.2 |2.1 |74.7 | | |------|---------|-------|-------------|------------------| | |1378 |117 |1.4 |2.5 |77.1 | | |------|---------|-------|-------------|------------------| | |1379 |95 |1.1 |2.0 |79.2 | | |------|---------|-------|-------------|------------------| | |1380 |107 |1.3 |2.3 |81.5 | | |------|---------|-------|-------------|------------------| | |1381 |139 |1.7 |3.0 |84.4 | | |------|---------|-------|-------------|------------------| | |1382 |123 |1.5 |2.6 |87.0 | | |------|---------|-------|-------------|------------------| | |1383 |126 |1.5 |2.7 |89.7 | | |------|---------|-------|-------------|------------------| | |1384 |129 |1.5 |2.7 |92.5 | | |------|---------|-------|-------------|------------------| | |1385 |115 |1.4 |2.5 |94.9 | | |------|---------|-------|-------------|------------------| | |1386 |119 |1.4 |2.5 |97.5 | | |------|---------|-------|-------------|------------------| | |1387 |64 |.8 |1.4 |98.8 | | |------|---------|-------|-------------|------------------| | |1388 |39 |.5 |.8 |99.7 | | |------|---------|-------|-------------|------------------| | |1389 |15 |.2 |.3 |100.0 | | |------|---------|-------|-------------|------------------| | |1390 |1 |.0 |.0 |100.0 | | |------|---------|-------|-------------|------------------| | |Total |4691 |56.2 |100.0 | | |-------|------|---------|-------|-------------|------------------| |Missing|System|3657 |43.8 | | | |--------------|---------|-------|-------------|------------------| |Total |8348 |100.0 | | | |-----------------------------------------------------------------| * list cases where cmc_lp and B3$01 don't agree if the last pregnancy was a birth. compute filter_$ = (lp > 0 & lp = lb & cmc_lp <> B3$01). print formats filter_$ (f1.0). filter by filter_$. * there shouldn't be any cases listed. list variables = lp cmc_lp B3$01. List Notes |-----------------------------|---------------------------------| |Output Created |31-AUG-2017 01:10:47 | |-----------------------------|---------------------------------| |Comments | | |--------------|--------------|---------------------------------| |Input |Filter |filter_$ | | |--------------|---------------------------------| | |Weight | | | |--------------|---------------------------------| | |Split File | | |-----------------------------|---------------------------------| |Syntax |list variables = lp cmc_lp B3$01.| |--------------|--------------|---------------------------------| |Resources |Processor Time|00:00:00.02 | | |--------------|---------------------------------| | |Elapsed Time |00:00:00.01 | |---------------------------------------------------------------| Number of cases read: 0 Number of cases listed: 0 filter off. * Example 2B. * -----------------------. * Find the duration of the pregnancy for the last birth or terminated pregnancy. * (continues from Example 2A). * Step 2.4. * get the position of the month prior to the pregnancy and the duration of pregnancy. * starting in the position after the birth loop and search the substring for the * first position that is not a "P" (pregnancy). * _bp means 'before pregnancy'. pos_bp means position before pregnancy. compute pos_bp = lp+1. * note that pos_bp cannot be zero or missing as it is used in the substring command following * it will be reset later. * loop through each position in the calendar (going back in time) until there is no "P". loop if (lp > 0 & pos_bp <= vcal_len & char.substr(vcal$1,pos_bp,1) = "P"). + compute pos_bp = pos_bp+1. end loop. * reset pos_bp to missing if there is no birth or if the respondent was already pregnant * in the first month of the calendar. if (lp = 0 or pos_bp > vcal_len) pos_bp = $sysmis. execute. variable labels pos_bp "Position before pregnancy". value labels pos_bp 0 "No pregnancy, or pregnant in first month of calendar". print formats pos_bp (f2.0). * e.g. if calendar is as below: * ______________00000BPPPPPPPP000000555555500000TPP00000000000000BPPPPPPPP00000000 * ^. * pos_bp would be 29. list variables = vcal$1 pos_bp /cases from 1 to 5. List Notes |---------------------------------------------|--------------------------------------------------| |Output Created |31-AUG-2017 01:10:47 | |---------------------------------------------|--------------------------------------------------| |Comments | | |--------------|------------------------------|--------------------------------------------------| |Input |Filter | | | |------------------------------|--------------------------------------------------| | |Weight | | | |------------------------------|--------------------------------------------------| | |Split File | | | |------------------------------|--------------------------------------------------| | |N of Rows in Working Data File|8348 | |---------------------------------------------|--------------------------------------------------| |Syntax |list variables = vcal$1 pos_bp /cases from 1 to 5.| |--------------|------------------------------|--------------------------------------------------| |Resources |Processor Time |00:00:00.02 | | |------------------------------|--------------------------------------------------| | |Elapsed Time |00:00:00.01 | |------------------------------------------------------------------------------------------------| The variables are listed in the following order: LINE 1: VCAL$1 LINE 2: pos_bp VCAL$1: 00000BPPPPPPPP00000000000000000000000BPPPPPPPP00000000000000000000 pos_bp: 29 VCAL$1: PPPPPP000000000000000000000000BPPPPPPPP000000000000000000000000000 pos_bp: 54 VCAL$1: 000000000000000000000000000000000000000000000000000000000000000000 pos_bp: . VCAL$1: 0000000000BPPPPPPPP00000000000BPPPPPPPP000000000000000000000000000 pos_bp: 34 VCAL$1: 0BPPPPPPPP000000000000000000000000BPPPPPPPP00000000000000000000000 pos_bp: 25 Number of cases read: 5 Number of cases listed: 5 * find the length of the pregnancy. if (pos_bp > 0) dur_preg = pos_bp - lp. variable labels dur_preg "Duration of pregnancy". print formats dur_preg (f2.0). frequencies variables=dur_preg. Frequencies Notes |-----------------------------------------------------|---------------------------------------------------| |Output Created |31-AUG-2017 01:10:47 | |-----------------------------------------------------|---------------------------------------------------| |Comments | | |----------------------|------------------------------|---------------------------------------------------| |Input |Filter | | | |------------------------------|---------------------------------------------------| | |Weight | | | |------------------------------|---------------------------------------------------| | |Split File | | | |------------------------------|---------------------------------------------------| | |N of Rows in Working Data File|8348 | |----------------------|------------------------------|---------------------------------------------------| |Missing Value Handling|Definition of Missing |User-defined missing values are treated as missing.| | |------------------------------|---------------------------------------------------| | |Cases Used |Statistics are based on all cases with valid data. | |-----------------------------------------------------|---------------------------------------------------| |Syntax |frequencies variables=dur_preg. | |----------------------|------------------------------|---------------------------------------------------| |Resources |Processor Time |00:00:00.02 | | |------------------------------|---------------------------------------------------| | |Elapsed Time |00:00:00.02 | |---------------------------------------------------------------------------------------------------------| Statistics dur_preg Duration of pregnancy |-|-------|----| |N|Valid |4409| | |-------|----| | |Missing|3939| |--------------| dur_preg Duration of pregnancy |--------------|---------|-------|-------------|------------------| | |Frequency|Percent|Valid Percent|Cumulative Percent| |-------|------|---------|-------|-------------|------------------| |Valid |1 |9 |.1 |.2 |.2 | | |------|---------|-------|-------------|------------------| | |2 |43 |.5 |1.0 |1.2 | | |------|---------|-------|-------------|------------------| | |3 |75 |.9 |1.7 |2.9 | | |------|---------|-------|-------------|------------------| | |4 |61 |.7 |1.4 |4.3 | | |------|---------|-------|-------------|------------------| | |5 |29 |.3 |.7 |4.9 | | |------|---------|-------|-------------|------------------| | |6 |15 |.2 |.3 |5.3 | | |------|---------|-------|-------------|------------------| | |7 |7 |.1 |.2 |5.4 | | |------|---------|-------|-------------|------------------| | |8 |80 |1.0 |1.8 |7.2 | | |------|---------|-------|-------------|------------------| | |9 |3506 |42.0 |79.5 |86.8 | | |------|---------|-------|-------------|------------------| | |10 |572 |6.9 |13.0 |99.7 | | |------|---------|-------|-------------|------------------| | |11 |12 |.1 |.3 |100.0 | | |------|---------|-------|-------------|------------------| | |Total |4409 |52.8 |100.0 | | |-------|------|---------|-------|-------------|------------------| |Missing|System|3939 |47.2 | | | |--------------|---------|-------|-------------|------------------| |Total |8348 |100.0 | | | |-----------------------------------------------------------------| * note that the duration of pregnancy cannot be calculated for births or pregnancies * where the pregnancy started in the first month of the calendar or before * as we don't know the real month the pregnancy started. * e.g. if calendar is as below: * ______________00000BPPPPPPPP000000555555500000TPP00000000000000BPPPPPPPP00000000 * |12345678^ * dur_preg would be 9 for the last pregnancy (1 B plus 8 Ps). list variables = vcal$1 lp dur_preg pos_bp /cases from 1 to 5. List Notes |---------------------------------------------|--------------------------------------------------------------| |Output Created |31-AUG-2017 01:10:47 | |---------------------------------------------|--------------------------------------------------------------| |Comments | | |--------------|------------------------------|--------------------------------------------------------------| |Input |Filter | | | |------------------------------|--------------------------------------------------------------| | |Weight | | | |------------------------------|--------------------------------------------------------------| | |Split File | | | |------------------------------|--------------------------------------------------------------| | |N of Rows in Working Data File|8348 | |---------------------------------------------|--------------------------------------------------------------| |Syntax |list variables = vcal$1 lp dur_preg pos_bp /cases from 1 to 5.| |--------------|------------------------------|--------------------------------------------------------------| |Resources |Processor Time |00:00:00.02 | | |------------------------------|--------------------------------------------------------------| | |Elapsed Time |00:00:00.02 | |------------------------------------------------------------------------------------------------------------| The variables are listed in the following order: LINE 1: VCAL$1 LINE 2: lp dur_preg pos_bp VCAL$1: 00000BPPPPPPPP00000000000000000000000BPPPPPPPP00000000000000000000 lp: 20 9 29 VCAL$1: PPPPPP000000000000000000000000BPPPPPPPP000000000000000000000000000 lp: 45 9 54 VCAL$1: 000000000000000000000000000000000000000000000000000000000000000000 lp: 0 . . VCAL$1: 0000000000BPPPPPPPP00000000000BPPPPPPPP000000000000000000000000000 lp: 25 9 34 VCAL$1: 0BPPPPPPPP000000000000000000000000BPPPPPPPP00000000000000000000000 lp: 16 9 25 Number of cases read: 5 Number of cases listed: 5 crosstabs /tables=dur_preg by lp_type /count=asis. Crosstabs Notes |-----------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------| |Output Created |31-AUG-2017 01:10:47 | |-----------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------| |Comments | | |----------------------|------------------------------|-------------------------------------------------------------------------------------------------------------------------------| |Input |Filter | | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | |Weight | | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | |Split File | | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | |N of Rows in Working Data File|8348 | |----------------------|------------------------------|-------------------------------------------------------------------------------------------------------------------------------| |Missing Value Handling|Definition of Missing |User-defined missing values are treated as missing. | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | |Cases Used |Statistics for each table are based on all the cases with valid data in the specified range(s) for all variables in each table.| |-----------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------| |Syntax |crosstabs /tables=dur_preg by lp_type /count=asis. | |----------------------|------------------------------|-------------------------------------------------------------------------------------------------------------------------------| |Resources |Processor Time |00:00:00.02 | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | |Elapsed Time |00:00:00.02 | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | |Dimensions Requested |2 | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | |Cells Available |131029 | |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| Case Processing Summary |----------------------------------------------------------------------------------|-------------------------------------------| | |Cases | | |-------------|---------------|-------------| | |Valid |Missing |Total | | |-----|-------|-------|-------|-----|-------| | |N |Percent|N |Percent|N |Percent| |----------------------------------------------------------------------------------|-----|-------|-------|-------|-----|-------| |dur_preg Duration of pregnancy * lp_type Birth or terminated pregnancy in calendar|4409 |52.8% |3939 |47.2% |8348 |100.0% | |------------------------------------------------------------------------------------------------------------------------------| dur_preg Duration of pregnancy * lp_type Birth or terminated pregnancy in calendar Crosstabulation Count |---------------------------------|----------------------------------------------------------------------|-----| | |lp_type Birth or terminated pregnancy in calendar |Total| | |-------------------------------------------------|--------------------| | | |Birth |Terminated pregnancy| | |------------------------------|--|-------------------------------------------------|--------------------|-----| |dur_preg Duration of pregnancy|1 |0 |9 |9 | | |--|-------------------------------------------------|--------------------|-----| | |2 |0 |43 |43 | | |--|-------------------------------------------------|--------------------|-----| | |3 |0 |75 |75 | | |--|-------------------------------------------------|--------------------|-----| | |4 |0 |61 |61 | | |--|-------------------------------------------------|--------------------|-----| | |5 |0 |29 |29 | | |--|-------------------------------------------------|--------------------|-----| | |6 |0 |15 |15 | | |--|-------------------------------------------------|--------------------|-----| | |7 |1 |6 |7 | | |--|-------------------------------------------------|--------------------|-----| | |8 |70 |10 |80 | | |--|-------------------------------------------------|--------------------|-----| | |9 |3496 |10 |3506 | | |--|-------------------------------------------------|--------------------|-----| | |10|572 |0 |572 | | |--|-------------------------------------------------|--------------------|-----| | |11|12 |0 |12 | |---------------------------------|-------------------------------------------------|--------------------|-----| |Total |4151 |258 |4409 | |--------------------------------------------------------------------------------------------------------------| * Example 2C. * -----------------------. * Find last method used before pregnancy in the last 5 year, even if not immediately before. * (continues from Example 2B). * Step 2.5. * find the last code that is not 0 before the pregnancy, * but not more than 5 years back. * lnz means 'last non-zero before the pregnancy'. compute pos_lnz = pos_bp. do if (pos_lnz > 0). + loop if (pos_lnz >= 1 & pos_lnz <= vcal_len & char.substr(vcal$1,pos_lnz,1) = "0"). + compute pos_lnz = pos_lnz+1. + end loop. end if. * if last non-zero is more than 5 years before interview, set position to 0. if (pos_lnz > v018+59) pos_lnz = 0. execute. variable labels pos_lnz "Position in calendar of last non-zero before pregnancy". value labels pos_lnz 0 "No non-zero preceding the pregnancy in the last 5 years". print formats pos_lnz (f2.0). * list a few cases to check. list variables = vcal$1 lp pos_bp pos_lnz /cases from 1 to 5. List Notes |---------------------------------------------|-------------------------------------------------------------| |Output Created |31-AUG-2017 01:10:47 | |---------------------------------------------|-------------------------------------------------------------| |Comments | | |--------------|------------------------------|-------------------------------------------------------------| |Input |Filter | | | |------------------------------|-------------------------------------------------------------| | |Weight | | | |------------------------------|-------------------------------------------------------------| | |Split File | | | |------------------------------|-------------------------------------------------------------| | |N of Rows in Working Data File|8348 | |---------------------------------------------|-------------------------------------------------------------| |Syntax |list variables = vcal$1 lp pos_bp pos_lnz /cases from 1 to 5.| |--------------|------------------------------|-------------------------------------------------------------| |Resources |Processor Time |00:00:00.00 | | |------------------------------|-------------------------------------------------------------| | |Elapsed Time |00:00:00.01 | |-----------------------------------------------------------------------------------------------------------| The variables are listed in the following order: LINE 1: VCAL$1 LINE 2: lp pos_bp pos_lnz VCAL$1: 00000BPPPPPPPP00000000000000000000000BPPPPPPPP00000000000000000000 lp: 20 29 52 VCAL$1: PPPPPP000000000000000000000000BPPPPPPPP000000000000000000000000000 lp: 45 54 0 VCAL$1: 000000000000000000000000000000000000000000000000000000000000000000 lp: 0 . . VCAL$1: 0000000000BPPPPPPPP00000000000BPPPPPPPP000000000000000000000000000 lp: 25 34 45 VCAL$1: 0BPPPPPPPP000000000000000000000000BPPPPPPPP00000000000000000000000 lp: 16 25 49 Number of cases read: 5 Number of cases listed: 5 * Step 2.6. * check if the respondent is using a method before the pregnancy but in the last 5 years. string code_lnz (A1). variable labels code_lnz "Last non-zero code before pregnancy". do if (pos_lnz >= 1 & pos_lnz <= v018+59). + compute code_lnz = char.substr(vcal$1, pos_lnz, 1). * if the code is NOT(!) a zero ("0"), a "B", "P", or "T" then the respondent was using a method. + compute used_bp = (char.index("0BPT",code_lnz) = 0). * char.index returns the position of code_lnz in the string 0BPT, * or 0 if it is not in the string. * char.index(...) = 0 will set used_bp to 1 (meaning using a method) * if code_lnz is NOT "0","B","P","T", * and will set used_bp to 0 (meaning NOT using a method) if the code is one of "0","B","P","T". else if (lp > 0). + compute code_lnz = "0". + compute used_bp = 0. end if. variable labels used_bp "Using a method before the last pregnancy". value labels used_bp 0 "No" 1 "Yes". print formats used_bp (f1.0). * list a few cases to check. list variables = vcal$1 lp pos_bp pos_lnz code_lnz used_bp /cases from 1 to 5. List Notes |---------------------------------------------|------------------------------------------------------------------------------| |Output Created |31-AUG-2017 01:10:47 | |---------------------------------------------|------------------------------------------------------------------------------| |Comments | | |--------------|------------------------------|------------------------------------------------------------------------------| |Input |Filter | | | |------------------------------|------------------------------------------------------------------------------| | |Weight | | | |------------------------------|------------------------------------------------------------------------------| | |Split File | | | |------------------------------|------------------------------------------------------------------------------| | |N of Rows in Working Data File|8348 | |---------------------------------------------|------------------------------------------------------------------------------| |Syntax |list variables = vcal$1 lp pos_bp pos_lnz code_lnz used_bp /cases from 1 to 5.| |--------------|------------------------------|------------------------------------------------------------------------------| |Resources |Processor Time |00:00:00.00 | | |------------------------------|------------------------------------------------------------------------------| | |Elapsed Time |00:00:00.01 | |----------------------------------------------------------------------------------------------------------------------------| The variables are listed in the following order: LINE 1: VCAL$1 LINE 2: lp pos_bp pos_lnz code_lnz used_bp VCAL$1: 00000BPPPPPPPP00000000000000000000000BPPPPPPPP00000000000000000000 lp: 20 29 52 B 0 VCAL$1: PPPPPP000000000000000000000000BPPPPPPPP000000000000000000000000000 lp: 45 54 0 0 0 VCAL$1: 000000000000000000000000000000000000000000000000000000000000000000 lp: 0 . . . VCAL$1: 0000000000BPPPPPPPP00000000000BPPPPPPPP000000000000000000000000000 lp: 25 34 45 B 0 VCAL$1: 0BPPPPPPPP000000000000000000000000BPPPPPPPP00000000000000000000000 lp: 16 25 49 B 0 Number of cases read: 5 Number of cases listed: 5 * Step 2.7. * last method used before pregnancy, but may have been followed by a period of non-use. * converting the string variable to numeric if desired, although it isn't really necessary for most analyses. * set up a list of codes used in the calendar, with each position matching the coding in V312. * use a tilde (~) to mark gaps in the coding that are not used for this survey * e.g. Emergency contraception and Standard days method do not exist in this calendar. * note that some of the codes are survey specific so this list may need adjusting. if (code_lnz <> " ") method_bp = char.index("123456789WNALCF~M~",code_lnz). * convert the missing code to 99. if (code_lnz = "?") method_bp = 99. * now check if there are any codes that were not converted, and change these to -1. if (method_bp = 0 & used_bp) method_bp = -1. * alternatively, * use the commands below to set up survey specific coding and recode * the method and/or reasons for discontinuation. * include the path to the insert file if needed. * load the macro for the recoding. *insert file="Calendar recoding.sps". * now recode the method and/or reason for discontinuation. *!Calendar_recoding code_lnz method_bp. * and skip the value labeling in step 2.8 as the insert file above includes the value labeling. * if no method was used, set method_bp to 0. if (used_bp = 0) method_bp = 0. * Step 2.8. * label the method variable and codes. variable labels method_bp "Method used before the last pregnancy (numeric)". value labels method_bp 0 "No method used" 1 "Pill" 2 "IUD" 3 "Injectable" 4 "Diaphragm" 5 "Condom" 6 "Female sterilization" 7 "Male sterilization" 8 "Periodic abstinence/Rhythm" 9 "Withdrawal" 10 "Other traditional method" 11 "Norplant" 12 "Abstinence" 13 "Lactational amenorrhea method" 14 "Female condom" 15 "Foam and Jelly" 16 "Emergency contraception" 17 "Other modern method" 18 "Standard days method" 99 "Missing" -1 "***Unknown code not recoded***". print formats method_bp (f2.0). frequencies variables=method_bp. Frequencies Notes |-----------------------------------------------------|---------------------------------------------------| |Output Created |31-AUG-2017 01:10:47 | |-----------------------------------------------------|---------------------------------------------------| |Comments | | |----------------------|------------------------------|---------------------------------------------------| |Input |Filter | | | |------------------------------|---------------------------------------------------| | |Weight | | | |------------------------------|---------------------------------------------------| | |Split File | | | |------------------------------|---------------------------------------------------| | |N of Rows in Working Data File|8348 | |----------------------|------------------------------|---------------------------------------------------| |Missing Value Handling|Definition of Missing |User-defined missing values are treated as missing.| | |------------------------------|---------------------------------------------------| | |Cases Used |Statistics are based on all cases with valid data. | |-----------------------------------------------------|---------------------------------------------------| |Syntax |frequencies variables=method_bp. | |----------------------|------------------------------|---------------------------------------------------| |Resources |Processor Time |00:00:00.03 | | |------------------------------|---------------------------------------------------| | |Elapsed Time |00:00:00.02 | |---------------------------------------------------------------------------------------------------------| Statistics method_bp Method used before the last pregnancy (numeric) |-|-------|----| |N|Valid |4409| | |-------|----| | |Missing|3939| |--------------| method_bp Method used before the last pregnancy (numeric) |-------------------------------------|---------|-------|-------------|------------------| | |Frequency|Percent|Valid Percent|Cumulative Percent| |-------|-----------------------------|---------|-------|-------------|------------------| |Valid |No method used |4090 |49.0 |92.8 |92.8 | | |-----------------------------|---------|-------|-------------|------------------| | |Pill |117 |1.4 |2.7 |95.4 | | |-----------------------------|---------|-------|-------------|------------------| | |IUD |4 |.0 |.1 |95.5 | | |-----------------------------|---------|-------|-------------|------------------| | |Injectable |122 |1.5 |2.8 |98.3 | | |-----------------------------|---------|-------|-------------|------------------| | |Condom |8 |.1 |.2 |98.5 | | |-----------------------------|---------|-------|-------------|------------------| | |Periodic abstinence/Rhythm |3 |.0 |.1 |98.5 | | |-----------------------------|---------|-------|-------------|------------------| | |Withdrawal |1 |.0 |.0 |98.5 | | |-----------------------------|---------|-------|-------------|------------------| | |Other traditional method |14 |.2 |.3 |98.9 | | |-----------------------------|---------|-------|-------------|------------------| | |Norplant |17 |.2 |.4 |99.3 | | |-----------------------------|---------|-------|-------------|------------------| | |Lactational amenorrhea method|33 |.4 |.7 |100.0 | | |-----------------------------|---------|-------|-------------|------------------| | |Total |4409 |52.8 |100.0 | | |-------|-----------------------------|---------|-------|-------------|------------------| |Missing|System |3939 |47.2 | | | |-------------------------------------|---------|-------|-------------|------------------| |Total |8348 |100.0 | | | |----------------------------------------------------------------------------------------| * list the first 15 cases that used before the pregnancy * anytime in the 5 years before interview. filter off. filter by used_bp. list variables = vcal$1 lp pos_lnz code_lnz method_bp /cases from 1 to 15. List Notes |---------------------------------------------|--------------------------------------------------------------------------| |Output Created |31-AUG-2017 01:10:47 | |---------------------------------------------|--------------------------------------------------------------------------| |Comments | | |--------------|------------------------------|--------------------------------------------------------------------------| |Input |Filter |used_bp Using a method before the last pregnancy | | |------------------------------|--------------------------------------------------------------------------| | |Weight | | | |------------------------------|--------------------------------------------------------------------------| | |Split File | | | |------------------------------|--------------------------------------------------------------------------| | |N of Rows in Working Data File|319 | |---------------------------------------------|--------------------------------------------------------------------------| |Syntax |list variables = vcal$1 lp pos_lnz code_lnz method_bp /cases from 1 to 15.| |--------------|------------------------------|--------------------------------------------------------------------------| |Resources |Processor Time |00:00:00.02 | | |------------------------------|--------------------------------------------------------------------------| | |Elapsed Time |00:00:00.01 | |------------------------------------------------------------------------------------------------------------------------| The variables are listed in the following order: LINE 1: VCAL$1 LINE 2: lp pos_lnz code_lnz method_bp VCAL$1: 1111111000000000000000000BPPPPPPPP001111111111111000000000000000000 lp: 39 50 1 1 VCAL$1: 3333333333333111111111111111110000000000000000BPPPPPPPP00001111111 lp: 61 74 1 1 VCAL$1: 11TPPP11111111111111111111111111111111111111111111111110000000BPPP lp: 17 21 1 1 VCAL$1: 000000000000BPPPPPPPP000333333333333333330000000000BPPPPPPPP00000000 lp: 25 37 3 3 VCAL$1: 00BPPPPPPPPP000NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN000000000000000 lp: 15 28 N 11 VCAL$1: NNN0000000000000000000000000000BPPPPPPPPP000011111111111111111111111 lp: 44 58 1 1 VCAL$1: 0000000BPPPPPPPP0033333333333333330000000000000000000000000000000000 lp: 20 31 3 3 VCAL$1: 000000000BPPPPPPPPP00111111111111111111111111111111111111110000000000 lp: 21 33 1 1 VCAL$1: 3333300TPPPPPP0000111111110BPPPPPPPP0000000000000000000000000000000 lp: 21 32 1 1 VCAL$1: 0000000000000000BPPPPPPPP00000000000033333333333333333333333333333 lp: 31 52 3 3 VCAL$1: 00000000BPPPPPPPP033333333333333333333300000000000000000000BPPPPPP lp: 23 33 3 3 VCAL$1: 00000000000000BPPPPPPPP1111111111110000000000000000BPPPPPPPP000000 lp: 29 38 1 1 VCAL$1: 00BPPPPPPPP11111111111NNNNNNNNNNNNNNNNNNNNNNNNN0000000000000000000 lp: 17 26 1 1 VCAL$1: 00000BPPPPPPPPPPNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN lp: 20 31 N 11 VCAL$1: 0000000000BPPPPPPPP0NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN000000BPPP lp: 25 35 N 11 Number of cases read: 15 Number of cases listed: 15 filter off. * Step 2.9. * compute the weight variable and weight the data. compute wt = v005/1000000. weight by wt. * crosstab the last method used prior to the pregnancy by the type of pregnancy outcome. crosstabs /tables=method_bp by lp_type /count=asis /cell=column count. Crosstabs Notes |-----------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------| |Output Created |31-AUG-2017 01:10:47 | |-----------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------| |Comments | | |----------------------|------------------------------|-------------------------------------------------------------------------------------------------------------------------------| |Input |Filter | | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | |Weight |wt | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | |Split File | | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | |N of Rows in Working Data File|8348 | |----------------------|------------------------------|-------------------------------------------------------------------------------------------------------------------------------| |Missing Value Handling|Definition of Missing |User-defined missing values are treated as missing. | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | |Cases Used |Statistics for each table are based on all the cases with valid data in the specified range(s) for all variables in each table.| |-----------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------| |Syntax |crosstabs /tables=method_bp by lp_type /count=asis /cell=column count. | |----------------------|------------------------------|-------------------------------------------------------------------------------------------------------------------------------| |Resources |Processor Time |00:00:00.02 | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | |Elapsed Time |00:00:00.03 | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | |Dimensions Requested |2 | | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | |Cells Available |131029 | |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| Case Processing Summary |-------------------------------------------------------------------------------------------------------------|--------------------------------------------------| | |Cases | | |----------------|----------------|----------------| | |Valid |Missing |Total | | |--------|-------|--------|-------|--------|-------| | |N |Percent|N |Percent|N |Percent| |-------------------------------------------------------------------------------------------------------------|--------|-------|--------|-------|--------|-------| |method_bp Method used before the last pregnancy (numeric) * lp_type Birth or terminated pregnancy in calendar|4333.308|51.9% |4014.692|48.1% |8348.000|100.0% | |----------------------------------------------------------------------------------------------------------------------------------------------------------------| method_bp Method used before the last pregnancy (numeric) * lp_type Birth or terminated pregnancy in calendar Crosstabulation |--------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------|--------| | |lp_type Birth or terminated pregnancy in calendar |Total | | |-------------------------------------------------|--------------------| | | |Birth |Terminated pregnancy| | |---------------------------------------------------------|-----------------------------|----------------------------------------------------------|-------------------------------------------------|--------------------|--------| |method_bp Method used before the last pregnancy (numeric)|No method used |Count |3726.587 |227.256 |3953.843| | | |----------------------------------------------------------|-------------------------------------------------|--------------------|--------| | | |% within lp_type Birth or terminated pregnancy in calendar|91.7% |84.2% |91.2% | | |-----------------------------|----------------------------------------------------------|-------------------------------------------------|--------------------|--------| | |Pill |Count |116.922 |17.928 |134.850 | | | |----------------------------------------------------------|-------------------------------------------------|--------------------|--------| | | |% within lp_type Birth or terminated pregnancy in calendar|2.9% |6.6% |3.1% | | |-----------------------------|----------------------------------------------------------|-------------------------------------------------|--------------------|--------| | |IUD |Count |3.082 |.207 |3.289 | | | |----------------------------------------------------------|-------------------------------------------------|--------------------|--------| | | |% within lp_type Birth or terminated pregnancy in calendar|0.1% |0.1% |0.1% | | |-----------------------------|----------------------------------------------------------|-------------------------------------------------|--------------------|--------| | |Injectable |Count |140.842 |14.974 |155.815 | | | |----------------------------------------------------------|-------------------------------------------------|--------------------|--------| | | |% within lp_type Birth or terminated pregnancy in calendar|3.5% |5.6% |3.6% | | |-----------------------------|----------------------------------------------------------|-------------------------------------------------|--------------------|--------| | |Condom |Count |8.831 |4.903 |13.734 | | | |----------------------------------------------------------|-------------------------------------------------|--------------------|--------| | | |% within lp_type Birth or terminated pregnancy in calendar|0.2% |1.8% |0.3% | | |-----------------------------|----------------------------------------------------------|-------------------------------------------------|--------------------|--------| | |Periodic abstinence/Rhythm |Count |3.023 |.000 |3.023 | | | |----------------------------------------------------------|-------------------------------------------------|--------------------|--------| | | |% within lp_type Birth or terminated pregnancy in calendar|0.1% |0.0% |0.1% | | |-----------------------------|----------------------------------------------------------|-------------------------------------------------|--------------------|--------| | |Withdrawal |Count |.809 |.000 |.809 | | | |----------------------------------------------------------|-------------------------------------------------|--------------------|--------| | | |% within lp_type Birth or terminated pregnancy in calendar|0.0% |0.0% |0.0% | | |-----------------------------|----------------------------------------------------------|-------------------------------------------------|--------------------|--------| | |Other traditional method |Count |13.720 |.691 |14.410 | | | |----------------------------------------------------------|-------------------------------------------------|--------------------|--------| | | |% within lp_type Birth or terminated pregnancy in calendar|0.3% |0.3% |0.3% | | |-----------------------------|----------------------------------------------------------|-------------------------------------------------|--------------------|--------| | |Norplant |Count |21.725 |1.272 |22.997 | | | |----------------------------------------------------------|-------------------------------------------------|--------------------|--------| | | |% within lp_type Birth or terminated pregnancy in calendar|0.5% |0.5% |0.5% | | |-----------------------------|----------------------------------------------------------|-------------------------------------------------|--------------------|--------| | |Lactational amenorrhea method|Count |27.988 |2.548 |30.536 | | | |----------------------------------------------------------|-------------------------------------------------|--------------------|--------| | | |% within lp_type Birth or terminated pregnancy in calendar|0.7% |0.9% |0.7% | |---------------------------------------------------------------------------------------|----------------------------------------------------------|-------------------------------------------------|--------------------|--------| |Total |Count |4063.529 |269.779 |4333.308| | |----------------------------------------------------------|-------------------------------------------------|--------------------|--------| | |% within lp_type Birth or terminated pregnancy in calendar|100.0% |100.0% |100.0% | |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|